﻿@model CNFM_CROCODILE_LOGO.Core.Domain.ViewModels.SignageApplicationReceiptModels

@{
    ViewData["Title"] = "申请单Edit";
}

<style>
    .wrap-45 {
        display: flex;
    }

        .wrap-45 .layui-form-select {
            flex: 1;
        }

            .wrap-45 .layui-form-select:nth-of-type(1) {
                margin-right: 10px;
            }
</style>
@section Scripts
    {
    <script type="text/javascript">
        var selfLayer = null, page = 1, active = null;
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form; //表格

            layui.laydate.render({
                elem: '#RegisteredTime',
                value: new Date()
            });


            //角色类型
            picker.GetTypeList(layui.form, { type: "产品类型" }, $("#typeId").val());

            form.on("select(Type)", function (data) {
                console.log(data.value);

                if (data.value == null || data.value == "")
                    $("#SpeciesId").empty();
                else
                    axios.get('/SignageApplication/GetSpeciesManageTypeAll', {
                        params: {
                            type: data.value
                        }
                    }).then(function (response) {
                        console.log("23456");
                        console.log(response.data);
                        if (response.data.code == 200) {
                            // $("#varCity").empty();
                            var options = '<option value="">请选择产品</option>';
                            var resultdata = response.data.result.data;
                            if (resultdata != null) {
                                for (var i = 0; i < resultdata.length; i++) {
                                    //if (data.value == resultdata[i].speciesName)
                                    //    options += '<option value="' + resultdata[i].id + '" selected>' + resultdata[i].speciesName + '</option>';
                                    //else
                                    options += '<option value="' + resultdata[i].id + '">' + resultdata[i].speciesName + '</option>';
                                }
                            }
                            if ($("#SpeciesId"))
                                $("#SpeciesId").html(options);
                            form.render();
                        } else {
                            console.log(response.data.msg)
                        }
                    }).catch(function (error) {
                        console.log(error);
                    });

                form.render();
            })


            //监听提交
            form.on('submit(submit)', function (data) {
                // data.field
                axios({
                    method: 'post',
                    url: '/SignageApplication/AddUpdateSignageApplication',
                    //headers: {
                    //    'content-type': 'application/x-www-form-urlencoded'
                    //},
                    data: data.field
                })
                    .then(function (response) {
                        console.log(response);
                        if (response.data.code == 200) {
                            javascript: history.go(-1);
                        } else {
                            alert(response.data.msg)
                        }

                    }).catch(function (error) {
                        console.log("添加失败!" + error);
                    });
                return false;
            });

        });
    </script>
}

<form class="layui-form layui-form-pane" asp-action="Edit">
    <div class="layui-form-item">
        <label class="layui-form-label">创建时间</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="RegisteredTime">
        </div>
    </div>
    <input type="hidden" id="speciesId" name="typeId" asp-for="SpeciesId" />
    <input type="hidden" id="typeId" name="typeId" asp-for="Type" />
    <div class="layui-form-item">
        <label class="layui-form-label">产品类别</label>
        <div class="layui-input-inline wrap-45">
            <select lay-search="" autocomplete="off" lay-verify="required" lay-filter="Type" asp-for="Type"></select>
            <select lay-search="" autocomplete="off" lay-verify="required" asp-for="SpeciesId"></select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请人</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="Person">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请数量</label>
        <div class="layui-input-block">
            <input type="number" class="layui-input w_545" autocomplete="off" lay-verify="required" asp-for="ApplyNum">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请备注</label>
        <div class="layui-input-block">
            <textarea asp-for="Purpose" style="width:545px;height:100px"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input class="layui-btn" type="button" style="width: 100px" lay-submit lay-filter="submit" value="立即提交" />
            <button type="reset" style="width: 100px" class="layui-btn layui-btn-primary">重置</button>
            <a style="width: 100px" class="layui-btn layui-btn-primary" asp-action="List">返回</a>
        </div>
    </div>
    <input type="hidden" asp-for="Id" />
</form>

